package fzdy.core.common;

/**
 * Created by Administrator on 2017/3/27 0027.
 */
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

public class StringArrayTool {
    public StringArrayTool() {
    }

    public static String ids2StringSort(List<Long> ids) {
        Collections.sort(ids);
        return ids2String(ids);
    }

    public static String ids2String(List<Long> ids, String sp) {
        StringBuilder sb = new StringBuilder("");
        if(ids != null) {
            Iterator var3 = ids.iterator();

            while(var3.hasNext()) {
                Object id = var3.next();
                sb.append(id).append(sp);
            }
        }

        return sb.toString();
    }

    public static String ids2String(List<Long> ids) {
        return ids2String(ids, ",");
    }

    public static List<Long> string2IdsSort(String idsStr) {
        ArrayList<Long> list = string2Ids(idsStr);
        Collections.sort(list);
        return list;
    }

    public static ArrayList<Long> string2Ids(String idsStr, String sp) {
        ArrayList<Long> list = new ArrayList();
        if(idsStr != null && !idsStr.isEmpty()) {
            String[] split = idsStr.split(sp);
            String[] var4 = split;
            int var5 = split.length;

            for(int var6 = 0; var6 < var5; ++var6) {
                String s = var4[var6];

                try {
                    long l = Long.parseLong(s);
                    list.add(Long.valueOf(l));
                } catch (Exception var10) {
                    ;
                }
            }
        }

        return list;
    }

    public static ArrayList<Long> string2Ids(String idsStr) {
        return string2Ids(idsStr, ",");
    }
}
